<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>在线考试系统登录页面</title>
    <link rel="stylesheet" type="text/css" href="${ctx}/common/css/reset.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/common/css/styles.css">
</head>
<body>

<div class="htmleaf-container">
    <div class="wrapper">

        <div class="container">
            <h1 id="add">在线考试系统登陆</h1> <br><br>
            <form class="form" id="longin_form" action="${ctx}/LoginServlet?methodName=userLogin" method="post">
                <input type="text" name="account" placeholder="请输入账户"/><br/>
                <input type="password" name="password" placeholder="请输入密码"/><br/>
                登录角色：<select id="role_type" name="role_type">
                        <option value="student">学生</option>
                        <option value="teacher">老师</option>
                        <option value="admin">管理员</option>
                    </select><br/>
                <input type="submit" value="登录"><input type="button" value="注冊" id="reg_id_bt">
            </form>
        </div>
        <ul class="bg-bubbles">
            <li>考试</li>
            <li>加油！</li>
            <li>考试</li>
            <li>加油！</li>
            <li>QAQ</li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
</div>


<script src="${ctx}/common/jquery/jquery-3.5.0.js" type="text/javascript"></script>
<script>
    $(document).ready(function(){
        $("#reg_id_bt").click(function(e){
            window.location.href="${ctx}/register.jsp";
        });
        $("#longin_form").submit(function(e){
            var account = $("input[name='account']").val();
                if(!account){
                    alert("请填写账号");
                    return false;
                }
                var password = $("input[name='password']").val();
                if(!password){
                    alert("请填写密码");
                    return false;
            }
            $(document).querySelector("#add").innerHTML='登录成功，正在进入...';
            $('#longin_form').fadeOut(200);
            // e.preventDefault();
            //如果验证不通过可以返回false
            // alert("Submit prevented");
        });
      /*  $('#login-button').click(function (event) {
            /!*document.querySelector("#add").innerHTML='登录成功，正在进入...';
            event.preventDefault();
            $('form').fadeOut(200);*!/
            //
            $("form").submit(function(e){
                e.preventDefault();
                alert("Submit prevented");
            });


        });*/

    });

</script>
</body>
</html>
